// 演示与语法
const arrayNumber: number[] = [1, 2, 3, 4]
// const greaterThan2: number = arrayNumber.find(num => num > 2)
// error 不能将类型“number | undefined”分配给类型“number”
// 因为在ts看来，可能不存在>2的情况为undefined
// 语法
const greaterThan2: number = arrayNumber.find(num => num > 2) as number
const greaterThan3: number = (<number>arrayNumber.find(num => num > 2))

// 非空断言
let mayNullOrUndefinedOrString: null | undefined | string
mayNullOrUndefinedOrString!.toString() // ok
// mayNullOrUndefinedOrString.toString() // error

// 确认赋值断言
// let x: number
let x!: number
initialize()
console.log(x *2)
function initialize() {
    x = 10
}